package com.stardata.liangshisq.tcslmon.config;
 
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class RabbitTopicConfig {

    private final String DATA_PUSH_EXCHANGE = "data.sender.exchange";

    private final String DATA_ORDER_TOPIC = "data.sender.order.topic";

    private final String DATA_KSC_TOPIC = "data.sender.ksc.topic";

    private final String DATA_ARCH_ITEM_TOPIC = "data.sender.arch.item.topic";

    private final String DATA_ARCH_POINT_TOPIC = "data.sender.arch.point.topic";

    //    交换机
    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(DATA_PUSH_EXCHANGE);
    }


    //    队列
    @Bean
    public Queue topicQueueA() {
        return new Queue(DATA_ORDER_TOPIC);
    }

    @Bean
    public Queue topicQueueB() {
        return new Queue(DATA_KSC_TOPIC);
    }

    @Bean
    public Queue topicQueueC() {
        return new Queue(DATA_ARCH_ITEM_TOPIC);
    }

    @Bean
    public Queue topicQueueD() {
        return new Queue(DATA_ARCH_POINT_TOPIC);
    }

 
//    绑定关系
    @Bean
    public Binding topicBindingA(){
        return BindingBuilder.bind(topicQueueA())
                .to(topicExchange())
                .with(DATA_ORDER_TOPIC);
    }

    @Bean
    public Binding topicBindingB(){
        return BindingBuilder.bind(topicQueueB())
                .to(topicExchange())
                .with(DATA_KSC_TOPIC);
    }

    @Bean
    public Binding topicBindingC(){
        return BindingBuilder.bind(topicQueueC())
                .to(topicExchange())
                .with(DATA_ARCH_ITEM_TOPIC);
    }

    @Bean
    public Binding topicBindingD(){
        return BindingBuilder.bind(topicQueueD())
                .to(topicExchange())
                .with(DATA_ARCH_POINT_TOPIC);
    }
 
 

 

 
 
}